#coding:utf-8
'''
* coder  : Dzlua
* email  : 505544956@qq.com
* module : api-frame
* path   : app/cmds
* file   : __init__.py
* time   : 2017/10/19
'''
#--------------------#
from app import mgr
#----------#
from app.utils.generate import generate_files
from app.utils.generate import generate_config
#----------#
from flask_migrate import MigrateCommand
#--------------------#

#--------------------#
mgr.manager.add_command('db', MigrateCommand)
#----------#
@mgr.manager.command
def deploy():
    '''deploy database.'''
    mgr.db.create_all()
#----------#
@mgr.manager.command
def dropall():
    '''drop all tables from database.'''
    mgr.db.drop_all()
#----------#
@mgr.manager.option( 'files', nargs='+', type=str,
    help='-> ... addfile app/file1.py app/cmds/file2 file3' )
@mgr.manager.option('--quiet', '-q', dest='quiet',
    default=False, action='store_true',
    help='generating files silently.')
def addfile(files, quiet):
    '''add files to this project.'''
    generate_files(files, quiet)
#----------#
@mgr.manager.option( '--quiet', '-q', dest='quiet',
    default=False, action='store_true',
    help='generating default config file silently.' )
def config(quiet):
    '''generate config file.'''
    generate_config(quiet)
#--------------------#
